package com.aduerr.v1shouyin.mvp.presenter;

import android.content.Context;
import android.util.Log;
import com.aduerr.v1shouyin.App;
import com.aduerr.v1shouyin.http.RXRequest;
import com.aduerr.v1shouyin.mvp.base.BasePresenter;
import com.aduerr.v1shouyin.mvp.view.CreatErweimaView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import javax.inject.Inject;
import java.util.HashMap;

/**
 * 类名: CreatErweimaPresenter
 * 此类用途: ---
 *
 * @Author: peixi
 * @Date: 2017-12-07 09:45
 * @Email: cr7inmanchester.com
 * @FileName: com.aduer.shouyin.mvp.presenter.CreatErweimaPresenter.java
 */
public class CreatErweimaPresenter extends BasePresenter<CreatErweimaView> {
    @Inject
    public CreatErweimaPresenter(App app) {
        super(app);
    }

    public void getErweima(final Context mContext, String realmoney, String beizhu) {
        HashMap<String, String> addParams = new HashMap<>();
//        getView().showProgress();
        addParams.put("payMoney", "" + realmoney);
        addParams.put("bz", "" + beizhu);
        getAppComponent().getAPIService().getErweimaBitmap(RXRequest.getXingPosParams(addParams, mContext))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(erwewimaResultEntity -> {
//                    if (Tools.isAvailable(erwewimaResultEntity)) return;
                    Log.e("response==",
                            "paramssage" + RXRequest.getXingPosParams(addParams,
                                    mContext));
                    if(isViewAttached())
                        getView().onCreatErweima(erwewimaResultEntity);
                }, throwable -> {

                });

    }

}
